<?php
namespace app\api\controller\site;
use app\api\controller\Init;

class Site extends Init
{
    public function initialize() {
        parent::initialize();
        $this->service = model('site/Site', 'service');
    }

    /**
     * 创建
     * @method create
     * @return [type] [description]
     */
    public function create()
    {
        $name = $this->request->post('name');
        $deadline = $this->request->post('deadline');
        $custom_id = $this->request->post('custom_id');
        $logo = $this->request->post('logo');
        $desc = $this->request->post('desc');
        $result = $this->service->create($name, $deadline, $custom_id, $logo, $desc);
        if (!$result) {
            return $this->response($this->service->getError(),[],-300101);
        }
        return $this->response("success", $result);

    }


    /**
     * 详情
     * @method create
     * @return [type] [description]
     */
    public function detail()
    {
        $site_id = $this->site['id'];
        $custom_id = $this->site['custom_id'];
        //$custom_id = $this->request->post('custom_id');
        $result = $this->service->detail($site_id,$custom_id);
        if (!$result) {
            return $this->response($this->service->getError(),[],-300101);
        }
        return $this->response("success", $result);
    }

}